<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 								
	<head> 							
		<%@ include file="../jslib/jquerylib.jsp" %>
	    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
        <link href="<%=request.getContextPath() %>/web/style/layout.css" type="text/css" rel="stylesheet"/>
        <link rel="stylesheet" href="<%=request.getContextPath() %>/jslib/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css"/>
        <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/ztree/jquery.ztree.core-3.4.js"></script>
        <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
	       <!-- 删除结果信息返回 -->
	    	<c:if test="${requestScope.message!=null}">
				<script type="text/javascript">
	  	 		     alert('<c:out value="${requestScope.message}"></c:out>');
	  	 		     window.close();
	  			</script>
	        </c:if>
	 
	<script type="text/javascript">
	$(document).ready(function(){
	
			
				//高级搜索需要的js
				buttonStatus=1;
				$("#flip").click(function(){
					if(buttonStatus==1){
						$("#panel").slideToggle("slow");
						$("#flip").toggleClass("btnStatus2");
						buttonStatus=1;
					}
					else{
						$("#panel").slideUp("slow");
						$("#flip").toggleClass("btnStatus2");
					}
			 });
				 //高级搜索结束
	
					$("#gridTable").jqGrid({
						url:'<%=request.getContextPath()%>/shebeiweibaojiluAction!queryShebeiweibaoList.action',
						datatype: "json",
						height: 450,
						width: 1010, 
						autowidth: true, 
						colNames:['ID','设备id','设备名称','维保项目','设备编号','规格型号','实施人员','部门id','部门名称','维保工时','计划维保时间','实际维保时间','维保成本','备件更换情况描述','备件出库单号','异常处置情况','维护保养建议','附件'],
                   		colModel:[
                        		{name:'ID',index:'ID', width:50, key:true,hidden:true,hidedlg:true}, 
                        		{name:'SHEBEIID',index:'SHEBEIID', width:10,hidden:true},
                        		{name:'SHEBEINAME',index:'SHEBEINAME', width:50},
                        		{name:'WEIBAOXIANGMU',index:'WEIBAOXIANGMU', width:50},	
								{name:'SHEBEINO',index:'SHEBEINO', width:50},
								{name:'GUIGEXINGHAO',index:'GUIGEXINGHAO', width:50},
								{name:'SHISHIRENYUAN',index:'SHISHIRENYUAN', width:50},								
								{name:'BUMENID',index:'BUMENID', width:10,hidden:true},
								{name:'BUMENNAME',index:'BUMENNAME', width:50},
								{name:'WEIBAOGONGSHI',index:'WEIBAOGONGSHI', width:50},
								{name:'JIHUAWEIBAOTIME',index:'JIHUAWEIBAOTIME', width:60},
								{name:'SHIJIWEIBAOTIME',index:'SHIJIWEIBAOTIME', width:60},
								{name:'WEIBAOCHENGBEN',index:'WEIBAOCHENGBEN', width:50},
								{name:'GENGHUANMIAOSHU',index:'GENGHUANMIAOSHU', width:50},
								{name:'CHUKUDANHAO',index:'CHUKUDANHAO',width:50},
								{name:'YICHANGCHUZHI',index:'YICHANGCHUZHI',width:50},
								{name:'WEIBAOJIANYI',index:'WEIBAOJIANYI', width:50},
								{name:'FUJIAN',index:'FUJIAN', width:50},
                    ],
					shrinkToFit:false,
					sortname:'id',
					sortorder:'desc',
					viewrecords:true,
					multiselect: true, // 是否显示复选框
					multiboxonly : true, 
					//gridview: true,  //提升速度
					rownumbers: true,//显示行号
					rownumWidth: 30, //行号的宽度
					rowNum:15,
					rowList:[15,20,50,200,500],
					toolbar: [false,"top"],
					loadComplete: function() {
					},
					jsonReader: {
						root:"rows",		// 数据行（默认为：rows）
						page: "page",  	// 当前页
						total: "total",  // 总页数
						records: "records",  // 总记录数
						repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
					},
					prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
					pager:"#gridPager",
					caption: "设备维保列表"
			});
			    $("#consoleDlg").dialog({
			        autoOpen: false,      
			        modal: true,    // 设置对话框为模态（modal）对话框  
			        resizable: true,      
			        width: 700,  
			        buttons: {  // 为对话框添加按钮  
			            "关闭": function() {$("#consoleDlg").dialog("close")}
			        }  
			    }); 
				 jQuery("#gridTable").jqGrid('navGrid','#gridPager',{add:false,edit:false,del:false,search:false,refresh:false});
					jQuery("#gridTable").jqGrid('navButtonAdd','#gridPager',
								{ 	
								caption: "",                          
								onClickButton : function (){                               
								jQuery("#gridTable").jqGrid('setColumns');                           
								}
					}); 
								doResize(); 
							//	afterCompleteFunction();
																
		}); 
	
	//执行大小
	function doResize() { 
		var ss = getPageSize(); 
		//alert(ss.WinH);
		
			 $("#gridTable").jqGrid('setGridHeight', ss.WinH-245);
			 $("#gridTable").jqGrid('setGridWidth', ss.WinW-30); 
			} 
	
		
		//查询
		function gridSearch(){
			var bumenname = $.trim(jQuery("#bumenname").val());
            var shebeiname = $.trim(jQuery("#shebeiname").val()); 
            var shebeino = $.trim(jQuery("#shebeino").val());
            var guigexinghao = $.trim(jQuery("#guigexinghao").val());
            var weibaoxiangmu = $.trim(jQuery("#weibaoxiangmu").val()); 
            var startweibaotime = $.trim(jQuery("#startweibaotime").val());
            var endweibaotime = $.trim(jQuery("#endweibaotime").val());
            var params = {  
                        "bumenname" : encodeURIComponent(bumenname),                           
                        "shebeiname" : encodeURIComponent(shebeiname),
                        "shebeino" : encodeURIComponent(shebeino),                           
                        "guigexinghao" : encodeURIComponent(guigexinghao),
                        "weibaoxiangmu" : encodeURIComponent(weibaoxiangmu),                           
                         "startweibaotime" : startweibaotime,
                        "endweibaotime" : endweibaotime
                         };
            var postData = $("#gridTable").jqGrid("getGridParam", "postData");
            $.extend(postData, params);
			jQuery("#gridTable").jqGrid('setGridParam',
			{
				url:'<%=request.getContextPath()%>/shebeiweibaojiluAction!queryShebeiweibaoList.action',
			}).trigger("reloadGrid", [{page:1}]);
        } 
       
		//刷新
		function refreshIt(){
			//resetSearch();
			jQuery("#gridTable").jqGrid('setGridParam',
			{
				url:'<%=request.getContextPath()%>/shebeiweibaojiluAction!queryShebeiweibaoList.action',
			}).trigger("reloadGrid", [{page:1}]);
		    
		}
		function reload(){
			refreshIt();
		}
		//清空
		function reset(){
			jQuery("#bumenname").val("");
			jQuery("#shebeiname").val("");
			jQuery("#shebeino").val("");
			jQuery("#guigexinghao").val("");	
			jQuery("#weibaoxiangmu").val("");
			jQuery("#startweibaotime").val("");
			jQuery("#endweibaotime").val("");
		}
		
	        
	      //页面上的刷新按钮
			function shuaXin(){
				reset();
				gridSearch();
			}
		
		
		function saveE(){
			 var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
			 var jilumingcheng = $.trim(jQuery("#jilumingcheng").val());
				if (!ids) {
				    alert("请先选择记录!");  
				    return false;  
				}else{
					$.ajax({  
					        url : "<%=request.getContextPath() %>/shebeiweibaojiluAction!saveWeibaojilu.action?flag=0&jilumingcheng="+jilumingcheng+"&jiluid=<%=request.getParameter("jiluid")%>&ids="+ids,
					        type : "post", 
					        //data : params,  
					        dataType : "json",  
					        cache : false,  
						    error : function(textStatus, errorThrown) {  
						        alert("系统ajax交互错误: " + textStatus.value);  
						    },  
						    success : function(data, textStatus) {  
				            	if(data.result=="success"){
					        		//alert("保存成功！");  
					        		window.close();  
					        	}else if(data.result=="error"){
					        		//alert("保存失败！"); 
					        		window.close();  
					        	}
						    }  
				        });
				} 
		}
	</script>	
	</head>
	<body>
	<form action="" method="post" id="form1">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
		   		<td>
			 		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="font12Black_B">
			   		<tr>
			        	<td width="6%" height="35" align="right">部门名称：</td>
			        	<td width="11%"><input type="text" name="bumenname" id="bumenname" class="search_InputText" style="width:99%;"/></td>
			        	<td width="9%" height="35" align="right">设备名称：</td>
			        	<td width="11%"><input type="text" name="shebeiname" id="shebeiname"  class="search_InputText" style="width:99%;" /> </td>
			        	<td width="6%" height="35" align="right">设备编号：</td>
			        	<td width="11%"><input type="text" name="shebeino" id="shebeino" class="search_InputText" style="width:99%;"/></td>
			        	<td width="9%" height="35" align="right">规格型号：</td>
			        	<td width="11%"><input type="text" name="guigexinghao" id="guigexinghao"  class="search_InputText" style="width:99%;" /> </td>
			            <td width="15%" align="right">&nbsp;<input type="button" name="button" id="button" value="查询" onclick="gridSearch()" class="search_Btn" />
			      			&nbsp;<input type="reset" name="button2" id="button2" value="清空" onclick="reset()" class="search_Btn" />
			      		</td>
			        </tr>
			      </table>
			      <div id="panel" style="display:none;">
			      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="font12Black_B">
			      	 <tr>
			        	<td width="6%" height="35" align="right">维保项目：</td>
			        	<td width="11%"><input type="text" name="weibaoxiangmu" id="weibaoxiangmu" class="search_InputText" style="width:99%;"/></td>
			        	<td width="8%" height="35" align="right">开始日期：</td>
			        	<td width="11%"><input type="text" name="startweibaotime" id="startweibaotime" onClick="WdatePicker()" class="search_InputText" style="width:99%;" /> </td>
			        	<td width="8%" height="35" align="right">结束时间：</td>
			        	<td width="11%"><input type="text" name="endweibaotime" id="endweibaotime" onClick="WdatePicker()" class="search_InputText" style="width:99%;" /> </td>
			            <td></td>
			        </tr>
			    </table>
			    </div>		    
		  		</td>
		 	  </tr>
		      <tr>
                <td align="right" height="9" class="sclinebotBg"></td>
	          </tr>
		      <tr>
			    <td width="92%" align="right"><div class="btnStatus" id="flip"></div></td>
			    <td width="8%">&nbsp;</td>
			  </tr>
			</table>
			<table style="width: 100%;" class="tableCont">
				<tr>
					<td width="6%" height="35" align="right">记录名称：</td>
			        <td width="11%"><input type="text" name="jilumingcheng" id="jilumingcheng" class="search_InputText" style="width:60%;"/></td>
			        <td align="center">
				    	<input id="saveBtn" type="button" value="确定" onclick="saveE()" class='button_b' />
				    	<input type="button" id="closeBtn" value="取消" class='button_b' />
			    	</td>
				</tr>
				<tr>
					<td colspan="4" style="padding-top:8px;">
						<table id="gridTable"></table>
						<div id="gridPager"></div>
					</td>
				</tr>
		   </table>
	</form>
	</body>
</html>
